//
//  UI_Mirror_VC.swift
//  APSwift
//
//  Created by jianbo.pei on 2023/7/16.
//

import UIKit

class UI_Mirror_VC: UIViewController {

    override func viewDidLoad() {
        super.viewDidLoad()

        // Do any additional setup after loading the view.
        
        let p = Person()
        let mirror = Mirror(reflecting: p)
        
        print("对象类型：\(mirror.subjectType)")
        print("对象属性个数：\(mirror.children.count)")
        print("对象的展示类型：\(String(describing: mirror.displayStyle))")
        print("对象的属性及属性值")
        for child in mirror.children {
            print("\(child.label!)---\(child.value)")
        }
    }
    
    class Person {
        var name: String = "jianbo.pei"
        var age: Int = 18
        var height = 1.85
    }

}
